<template>
  <el-button type="text"
             @click="download">下载</el-button>
</template>

<script>
import cert from '@/api/modules/cert'

export default {
  name: 'DigitalReceiptDownload',
  props: {
    query: {
      type: Object,
      default: () => { }
    }
  },
  methods: {
    download () {
      this.confirm(this.query?.certId)
    },
    async confirm (certId) {
      let params = {
        certId: certId,
        downloadSource: 3,
        fileType: 2,
        ip: '192.168.1.43:8080'         // 暂时写死
      }
      let response = await cert.getCertCheckDownload(params)
      let { count, url } = response.data
      window.location.href = url
      this.$message({ type: "success", message: `操作成功，剩余${count || 0}次下载次数` });
      return response;
    }
  }
}
</script>

<style>
</style>